//pack11jsclass

var SpecialsManager = new specialsManager();

function specialsManager() {

    this.cid=0;
    this.lid=0

    this.setState = function(e) {
        eid=e.id.replace("_text","");
        tmp=eid.split("_");
        SpecialsManager.cid=tmp[1];
        SpecialsManager.lid=tmp[0]+"_"+tmp[1];
        //alert(SpecialsManager.cid);

        old=document.getElementById(eid+"_extra").value;
        savebutton=document.getElementById(SpecialsManager.lid+"_save");

        if(e.value==old) {
            savebutton.style.display="none";
            e.className="textinput"
        } else {
            savebutton.style.display="block";
            e.className="changed"
        }
    }

    this.save = function(e) {
        tmp=e.split("_");
        SpecialsManager.cid=tmp[1];
        //lid="ti_"+tmp[1]+"_"+tmp[2];

        langs=document.getElementById("languages").value.split(",");
        //Trace("id: "+SpecialsManager.cid);

        ajax_id=new ajaxVar();
        ajax_id.name="item_id";
        ajax_id.value=SpecialsManager.cid;
        //alert(e);
        AjaxManager.variables.push(ajax_id.query());

        ajax_priority=new ajaxVar();
        ajax_priority.name="priority";
        ajax_priority.value=document.getElementById(SpecialsManager.lid+"_priority_text").value;
        AjaxManager.variables.push(ajax_priority.query());

        for(tr=0; tr<langs.length; tr++) {
            ajax_lang=new ajaxVar();
            ajax_lang.name="lang"+langs[tr];
            ajax_lang.value=document.getElementById(SpecialsManager.lid+"_"+langs[tr]+"_text").value;
            AjaxManager.variables.push(ajax_lang.query());
        }

        AjaxManager.url="?response=SpecialsManagerResponder";
        AjaxManager.backHandler=SpecialsManager.ajaxHandler;
        document.getElementById(SpecialsManager.lid+"_save").style.display="none";
        document.getElementById(SpecialsManager.lid+"_loader").style.display="block";
        AjaxManager.callServer();

    }

    this.ajaxHandler = function(text,xml) {
        //alert(text);
        if(text.indexOf("error")==-1) {
            langs=document.getElementById("languages").value.split(",");
            document.getElementById(SpecialsManager.lid+"_priority_text").className="textinput";
            for(tr=0; tr<langs.length; tr++) {
                document.getElementById(SpecialsManager.lid+"_"+langs[tr]+"_text").className="textinput";
                document.getElementById(SpecialsManager.lid+"_"+langs[tr]+"_extra").value=document.getElementById(SpecialsManager.lid+"_"+langs[tr]+"_text").value;
            }
        }
        document.getElementById(SpecialsManager.lid+"_loader").style.display="none";
    }
	
}